package com.hschinese.pronunciation.utils;

import com.google.gson.Gson;

public class GsonUtils {
	private static GsonUtils gsonUtils = null;
	
	public static GsonUtils getInstance(){
		if(null == gsonUtils){
			gsonUtils = new GsonUtils();
		}
		return gsonUtils;
	}
	
	public String toJson(Object object) {
		Gson gson = new Gson();
		return gson.toJson(object);
	}

	public Object fromJson(String json, Class<?> zlass) {
		Object obj = null;
		try {
			Gson gson = new Gson();
			obj = gson.fromJson(json, zlass);
		} catch (Exception e) {
			return obj;
		}
		return obj;
	}

}
